< previous page page_348 next page >

Page 348
for some constant k. This makes both tangent vectors <Vx2, Vy2> and <Wx1, Wy1> point in the same direction. The value of the constant k depends on the relative lengths of the tangent vectors.
Bezier Curves
Hermite curves have a couple of drawbacks. First, specifying tangent vectors is not a very intuitive process. Second, the tangent vectors must be fairly large for most interesting curves. That means you need to make large changes to the vectors to make a noticeable effect on the shape of the curve. Bezier curves address both of these problems.
Bezier curves are very similar to Hermite curves. Instead of specifying the tangent vectors for the curve explicitly, however, in a Bezier curve you specify two new control points that determine the tangent vectors indirectly. The tangent vector at the first endpoint is three times the vector connecting the first endpoint to the first new control point. The tangent vector at the second endpoint is three times the vector connecting the second new control point and the second endpoint. In other words, if the two new control points have coordinates (x1, y1) and (x2, y2), then:
e10a6a0a59f035e870d90cca05b85fce.gif
Vx1 = 3 * (X1 - Ex1)
V
y1 = 3 * (Y1 - Ey1)
V
x2 = 3 * (Ex2 - X2)
V
y2 = 3 * (Ey2 - Y2)
The factors of three in these equations give the new control points more influence over the shape of the curve.
If you substitute these values into the equations for the Hermite parameters ax, bx, cx, dx, ay, by, cy, and dy, you get:
e10a6a0a59f035e870d90cca05b85fce.gif
ax    = 3 * (Ex2 - x2) + 3 * (x1 - Ex1) - 2 * Ex2 + 2 * Ex1
      = Ex2 - Ex1 - 3 * x2 + 3 * x1
bx    = 3 * (Ex2 - 2 * 3 * (x1 - Ex1) - 3 * Ex1 - 3 * (Ex2 - x2)
      = 3 * E
x1 - 6 * x1 + 3 * x2
cx    = -3 * Ex1 + 3 * x1
dx    = Ex1
Using these equations, you can write a program similar to program Hermite to draw Bezier curves. Example program Bezier, shown in Figure 11.16, is such a program. Use the mouse to drag the curve's endpoints and control points to new positions, and the program displays the appropriate curve.
If you check the Show Control Points check box, the program also draws the endpoints and the control points. You can use the Go button to redraw the curve if you change the value of dt.

 
< previous page page_348 next page >